Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix encoded image being suggested for non-image blobs (like video) #7428

Merged
merged 2 commits into from
Sep 17, 2024

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Sep 16, 2024

What

Before:
image

After, the button is greyed out.

Made sure images still work fine by dragging in an image.

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG
  • If applicable, add a new check to the release checklist!
  • If have noted any breaking changes to the log API in CHANGELOG.md and the migration guide

To run all checks from main, comment on the PR with @rerun-bot full-check.

@Wumpf Wumpf added 🪳 bug Something isn't working 📺 re_viewer affects re_viewer itself include in changelog labels Sep 16, 2024
Copy link
Member

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

Comment on lines +51 to +57
fn update_applicability(&mut self, event: &re_chunk_store::ChunkStoreEvent) -> bool {
diff_component_filter(event, |media_type: &re_types::components::MediaType| {
media_type.is_image()
}) || diff_component_filter(event, |image: &re_types::components::Blob| {
MediaType::guess_from_data(&image.0).map_or(false, |media| media.is_image())
})
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not new to this PR, but I think there is room for improvement of the naming of these things, maybe:

Suggested change
fn update_applicability(&mut self, event: &re_chunk_store::ChunkStoreEvent) -> bool {
diff_component_filter(event, |media_type: &re_types::components::MediaType| {
media_type.is_image()
}) || diff_component_filter(event, |image: &re_types::components::Blob| {
MediaType::guess_from_data(&image.0).map_or(false, |media| media.is_image())
})
}
fn is_applicable(&mut self, event: &re_chunk_store::ChunkStoreEvent) -> bool {
is_any_component(event, |media_type: &re_types::components::MediaType| {
media_type.is_image()
}) || is_any_component(event, |image: &re_types::components::Blob| {
MediaType::guess_from_data(&image.0).map_or(false, |media| media.is_image())
})
}

Also, does this really need &mut self?

anyway, no need to fix now. Just thinking out loud.

Copy link
Member Author

@Wumpf Wumpf Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not gonna change the trait and all associated implemenations now in this PR ;)

The semantics of update are correct and very relevant as this is an incremental and stateful update of the applicability. Details are on the trait's documentation

Copy link
Member Author

@Wumpf Wumpf Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&mut self is for convenience if a trait implementor wants to track additional data that influence applicability

@Wumpf Wumpf merged commit d9456a8 into main Sep 17, 2024
33 of 34 checks passed
@Wumpf Wumpf deleted the andreas/fix-image-suggested-for-non-image-blob branch September 17, 2024 08:20
@emilk emilk changed the title Fix encoded image being suggested for non image blobs (like video) Fix encoded image being suggested for non-image blobs (like video) Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪳 bug Something isn't working include in changelog 📺 re_viewer affects re_viewer itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants